//
//  HistoryListModel.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/28.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "HistoryListModel.h"
#import "HistoryOrderViewController.h"


@interface HistoryListModel ()

@end

@implementation HistoryListModel



+(instancetype)modelWithDictionary:(NSDictionary *)dic{
    
    HistoryListModel *model =[[HistoryListModel alloc] init];
    
    [model setValuesForKeysWithDictionary:dic];
    
    return model;
}


+(void)historyListWithSucess:(void (^)(NSArray<HistoryListModel *> *))sucessBlock error:(void (^)())errorBlock{
    
//    NSDictionary * parameters = @{@"page":@"1",@"size":@"999"};
    
    
    [[NetworkTool sharedTools] POST:@"user/trades" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *  _Nullable responseObject) {
        
//        NSLog(@"==%@",responseObject);
        
        NSArray * paramArray = responseObject[@"param"];
        
        NSMutableArray *mArray = [NSMutableArray array];
        
        [paramArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            HistoryListModel * model = [HistoryListModel modelWithDictionary:obj];
            
            [mArray addObject:model];
            
        }];
        
        mArray = (NSMutableArray *)[[mArray reverseObjectEnumerator] allObjects];
        
        if(sucessBlock){
            
            sucessBlock(mArray.copy);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
}


@end
